<?php
/**
 * 预立项申请操作类
 *
 */
class CompanyClass extends FrameWork {
	/**
	 * 信息列表 
	 * @author workflow Develop Team     
	 * @param  $condition,$obj_page
	 * @return array
	 */
	function listCompany($condition,&$obj_page){
		$company_array = $GLOBALS['db']->GetList($condition, $obj_page, "company");
		return $company_array;
	}
	
	/**
	 * 信息添加 
	 * @author workflow Develop Team     
	 * @param  $value_array
	 * @return bool
	 */
	function addCompany($value_array){
		if (is_array($value_array)){
			$valueArray = array();
			foreach ($value_array as $k => $v){
				if ($v != ''){
					$valueArray[$k] = $v;
				}
			}
			$result = $GLOBALS['db']->InsertRow($valueArray,"company","id");
			unset($value_array,$valueArray);
			return $result;
		}
		return false;
	}
	
	/**
	 * 取信息
	 * @author workflow Develop Team     
	 * @param  $id
	 * @return array
	 */
	function getCompany($id,$type='simple'){
		if (intval($id) > 0){
			if ($type == 'simple'){
				$value_array = $GLOBALS['db']->GetOneRow(intval($id),'company','id');
			}else if ($type == 'more'){
				//$value_array = $GLOBALS['db']->GetOneJoinArray(array('company','news_class'),"left join",array("news.news_c_id=news_class.news_c_id"),array('*','news_c_name'),"and news.news_id='". intval($id) ."'",array(" news_c_id desc"));
			}
			return $value_array;
		}
		return false;
	}
	
	/**
	 * 修改信息
	 * @author workflow Develop Team     
	 * @param  $value_array
	 * @return bool
	 */
	function updateCompany($value_array){
		if (is_array($value_array) && intval($value_array['id']) > 0){
			$valueArray = array();
			foreach ($value_array as $k => $v){
				$valueArray[$k] = $v;
			}
			$result = $GLOBALS['db']->UpdateRow(intval($valueArray['id']), $valueArray, 'company', 'id');
			unset($value_array,$valueArray);
			return $result;
		}
		return false;
	}
	
	/**
	 * 删除信息
	 * @author workflow Develop Team     
	 * @param  $id
	 * @return bool
	 */
	function delCompany($id){
		if (intval($id) > 0){
			//$result = $GLOBALS['db']->DeleOneRow(intval($id),'company','id');
			$valueArray = array();
			$valueArray['id'] = $id;
			$valueArray['status'] = 0;
			$result = $GLOBALS['db']->UpdateRow(intval($id), $valueArray, 'company', 'id');
			unset($valueArray);
			return $result;
		}
		return false;
	}
	
	/**
	 * 添加关系 
	 * @author workflow Develop Team     
	 * @param  $value_array
	 * @return bool
	 */
	function addCompanywith($value_array){
		if (is_array($value_array)){
			$valueArray = array();
			foreach ($value_array as $k => $v){
				if ($v != ''){
					$valueArray[$k] = $v;
				}
			}
			$result = $GLOBALS['db']->InsertRow($valueArray,"companywith","id");
			unset($value_array,$valueArray);
			return $result;
		}
		return false;
	}
	
	/**
	 * 解除关系 
	 * @author workflow Develop Team     
	 * @param  $id
	 * @return bool
	 */
	function unCompanywith($id){
		if (intval($id) > 0){
			$valueArray = array();
			$valueArray['id'] = $id;
			$valueArray['status'] = 0;
			$result = $GLOBALS['db']->DeleOneRow(intval($id), 'companywith', 'id');
			unset($valueArray);
			return $result;
		}
		return false;
	}
	
	/**
	 * 关系列表 
	 * @author workflow Develop Team     
	 * @param  $condition,$obj_page
	 * @return array
	 */
	function listCompanywith($condition){
		$company_array = $GLOBALS['db']->GetList($condition, $obj_page, "companywith");
		return $company_array;
	}
}
?>